﻿using Moki.Exceptions;
using Moki;
using Moki.Tests.Model;
using NUnit.Framework;

namespace Moki.Specification
{
    [TestFixture]
    public class MockSpec
    {
        [TearDown]
        public void TearDown()
        {
            Mock.CleanUp();
        }

        [Test]
        [ExpectedException(typeof(CallConstraintsException))]
        public void Strict_mock_behavior()
        {
            ITests test = Mock.Create<ITests>(CallConstraints.Strict);

            test.DoSomething();
        }

        [Test]
        public void Loose_mock_behavior()
        {
            ITests test = Mock.Create<ITests>();

            test.DoSomething();
        }

        [Test]
        public void Loose_mock_should_return_default_values()
        {
            var def = Mock.Create<IDefaultValues>();

            def.Void();
            Assert.AreEqual(0, def.Int());
            Assert.AreEqual(0, def.Int());
            Assert.AreEqual(0, def.Double());
            Assert.AreEqual(false, def.Bool());
            Assert.AreEqual(null, def.String());
            Assert.AreEqual(null, def.Ref());
            Assert.AreEqual('\0', def.Char());

            Assert.AreEqual(0, def.PInt);
            Assert.AreEqual(0, def.PInt);
            Assert.AreEqual(0, def.PDouble);
            Assert.AreEqual(false, def.PBool);
            Assert.AreEqual(null, def.PString);
            Assert.AreEqual(null, def.PRef);
            Assert.AreEqual('\0', def.PChar); 
        }
    }
}
